GtkTextView: various scroll fixes
authorSebastien Lafargue <slafargue@gnome.org>
Sat, 29 Aug 2015 08:49:07 +0000 (10:49 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 2 Sep 2015 02:42:23 +0000 (22:42 -0400)
commit9ad6ac0b4330b3d8fd3da101b594210464a9f942
tree1c716be0fec36e21278294abbf918d06c18281cb
parent90bcde5951c90f27e0b362d4689e1c2afdc0860c
GtkTextView: various scroll fixes

The purpose of this patch is to fix regressions in GtkTextView
scroll behaviours due to commit d138156.
( addition of padding and margins to the view )

Adding some padding is done by, for example, in inspector css tab with:

GtkTextView {
  padding: 10px 10px 10px 10px;
}

and adding margins, by changing one of *-margin properties
( * standing for left/right/top/bottom ) or the corresponding
accessor functions.

Understand that none of these bugs are easy to trigger.
What's happened is that a old and wrong version of the code of the code
( lost in the mean time ) was pushed.

These bugs are best seen with wrap mode set to off.

The commit 8baab8f fix a first regression.

This one is about:

- Cursor going out of the view at line ends instead of being visible
  or triggering the horizontal scroll.

- Padding not displayed correctly
  when moving cursor at beginning/end of lines

- When horizontal scroll position not at left, cursor can make scroll
  by more than one character (you need left padding to see this )

- Moving the cursor arround, the rendered text can be shitted in x or y.
  ( fixed by converting adjustment float values
  to integer before calculations )

  It can be observed by going down with the cursor more
  than the view height then going up

- retval return value of _gtk_text_view_scroll_to_iter wrong in some cases

In addition, this patch re-factor priv->top_border
in screen_dest.y calculation

Of course, all GtkTextView and GtkSourceView based app were impacted
by these bugs ( gedit for example, see bug 754147 )

https://bugzilla.gnome.org/show_bug.cgi?id=753815

https://bugzilla.gnome.org/show_bug.cgi?id=75815
gtk/gtktextview.c